﻿using System.Configuration;

namespace Development.Tools
{
    /// <summary>
    /// configuration util
    /// </summary>
    public class ConfigUtil
    {
        public static string AppSetting(string key)
        {
            return ConfigurationManager.AppSettings[key];
        }

        public static int AppInt(string key)
        {
            return int.Parse(ConfigurationManager.AppSettings[key]);
        }

        public static float AppFloat(string key)
        {
            return float.Parse(ConfigurationManager.AppSettings[key]);
        }

        public static string GetSectionValue(string section,string key)
        {
            object appSettingSection = ConfigurationManager.GetSection(section);
            return null;
            //return appSettingSection.Settings[key].Value;
        }


        public static ConnectionStringSettings GetConnectionSetting(string name)
        {
            foreach (ConnectionStringSettings connection in ConfigurationManager.ConnectionStrings)
            {
                if (connection.Name == name)
                {
                    return connection;
                }
            }
            return null;
        }

    }
}
